package com.dongdongmovie.controller;

import com.dongdongmovie.pojo.PageResult;
import com.dongdongmovie.pojo.TabUser;
import com.dongdongmovie.service.TabUser_Service;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("TabUser")
public class TabUser_Controller {

    //注入service
    @DubboReference
    private TabUser_Service tabUser_service;

    //跳转show
    @RequestMapping("tzshow")
    public String tzshow() {
        return "TabUser/show";
    }

    //跳转update
    @RequestMapping("tzupdate")
    public String tzupdate(Integer uid, Model m) {
        TabUser t = tabUser_service.showbyId(uid);
        m.addAttribute("t", t);
        return "TabUser/update";
    }

    //分页模糊查询全部
    @ResponseBody
    @RequestMapping("show")
    public PageResult<TabUser> show(TabUser u, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "8") Integer pageSize) {
        PageResult<TabUser> page = tabUser_service.show(u, pageNum, pageSize);
        return page;
    }

    //添加数据
    @ResponseBody
    @RequestMapping("add")
    public int add(TabUser t) {
        return tabUser_service.add(t);
    }

    //修改数据
    @ResponseBody
    @RequestMapping("updatebyId")
    public int updatebyId(TabUser t) {
        return tabUser_service.updatebyId(t);
    }

}
